﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts; 
using Common;

public partial class admin__root_TopMenuBar : PageBase
{
    public string CurrentMenuId = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        PageBegin();

        if (!IsPostBack)
        {
            string arrRoleId = "", SQL = "";
            string _roleid = this.RoleId;
            for (int i = 0; i < _roleid.Split('|').Length; i++)
            {
                arrRoleId += "'" + _roleid.Split('|')[i] + "',";
            }
            if (arrRoleId != "")
            {
                arrRoleId += "|";
                arrRoleId = arrRoleId.Replace(",|", "");

                SQL += " AND CatalogId IN (SELECT DISTINCT CatalogId FROM PersonalizationCatalog WHERE OwnerId IN (" + arrRoleId + "))";
            }
            else { SQL += " AND 1 <> 1"; }

            DataTable datMenu = BLL.CommonBLL.Select("System_CatalogBase", "*", SQL + " AND Layer = 1 AND Number <> '00002' AND DeletionStateCode = 0 ORDER BY [Sort] ASC");
            rptTopMenuBar.DataSource = datMenu;
            rptTopMenuBar.DataBind();

            CurrentMenuId = BLL.CommonBLL.ExecuteScalar("System_CatalogBase", "TOP 1 CatalogId", SQL + " AND Layer = 1 AND Number <> '00002' AND DeletionStateCode = 0 ORDER BY [Sort] ASC").ToString();

            spanUserName.InnerHtml = this.UserInfo.FullName + ",";
        }
    }
}
